<template>
<div>

<el-row>

<el-form :inline="true" :model="form" >
	

	<el-form-item >
	    <el-input v-model="form.ticket_code" placeholder="票码"></el-input>
	</el-form-item>

    <el-form-item >
	    <el-input v-model="form.title" placeholder="订单名称"></el-input>
	</el-form-item>

	

	<el-form-item>
	    <el-button type="primary" @click="onSubmit">查询</el-button>
	</el-form-item>

</el-form>
</el-row>

<el-row>

<el-table
    :data="orderList.results"
    border
    style="width: 100%">
    <el-table-column
      prop="title"
      label="事件"
      width="300">
    </el-table-column>
    <el-table-column
      prop="name"
      label="姓名"
      width="100">
    </el-table-column>
    <el-table-column
      prop="cardno"
      label="身份证"
      width="200">
    </el-table-column>
    <el-table-column
      prop="stateLabel"
      label="状态"
      width="100">
      
    </el-table-column>
    <el-table-column
      label="操作">
      	<template slot-scope="scope">
      		<el-button type="warning" size="mini" 
      		@click="info(scope.row)">
      		详情</el-button>
      	</template>
    </el-table-column>
  </el-table>

</el-row>


<el-row class="text-right mt20 mb20">
<el-pagination
  @size-change="handleSizeChange"
  @current-change="handleCurrentChange"
  :current-page="pageNo"
  :page-size="pageSize"
  layout="total, sizes, prev, pager, next"
  :total="orderList.totalRecord">
</el-pagination>
</el-row>


</div>
</template>

<script>

import { mapGetters } from 'vuex'

export default {
	
	name : 'eventlist',
	
	data () {
		return {

			form : {},

			orderList : {},

			pageNo : 1,
			pageSize : 10,

			stateLabel : [
				'待审批',		//0
				'已审批',		//1
				'已办结',		//2
				'审批不通过',	//3
				'已填写',		//4
				'',			//5
				'',			//6
				'',			//7
				'',			//8
				'草稿',			//9
				''
			],
		}
	},

	props : {

	},

	components : {
		
	},

	computed : {
		...mapGetters([
			
		]),
	},

	methods : {

		onSubmit () {

		},

		init () {
			this.$http({
				fun : 'orderList',
				pageNo : this.pageNo,
				pageSize : this.pageSize,
				cb : res => {
					console.log(res);
					
					res.results.forEach(item => {
						console.log(item.state);
						item['stateLabel'] = this.stateLabel[parseInt(item.state)];
					});
					this.orderList = res;
				}
			});
		},

		handleSizeChange (val) {
			this.pageSize = val;
			this.init();
		},

		handleCurrentChange (val) {
			this.pageNo = val;
			this.init();
		},

		info (item) {
			console.log(item);

			this.$router.push({
				name : 'eventinfo',
				query : {
					code : item.code,
					id : item.item_id,
				}
			});
		},

	},

	watch : {
	    
	},

	mounted () {
		this.init();
	},


}
</script>

<style scoped>

</style>
